<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<fmt:setBundle basename="messages"/>
<script type="text/javascript">
function submitInstructionPurchase(form, orderField, orderType){
	form.orderField.value = orderField;
	form.orderType.value = orderType;
	form.action = "instructionPurchaseCreateList.do";
	if (validSubmit){
		form.submit();
	} else {
		alert('<bean:message key="warning.message.common.processing"/>');
	}
}
</script>
<html:form action="/instructionPurchaseCreateList" method="POST">
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>
	<table align="center" width="97%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
		<tr>
			<td colspan="13" class="titulocolumna" align="center"><bean:message key="menu.module.corn.instructionpurchase.create"/></td>
		</tr>
		<tr>
			<td class="etiqueta" width="3%"><bean:message key="label.purchases.instructions.reference"/>:</td>
			<td class="etiqueta_campo"  width="6%" >
				<html:text property="instructionPurchaseSearchView.reference"  styleClass="campo_texto" size="7" maxlength="10"></html:text>
			</td>
			<td class="etiqueta" width="4%" align="center"><bean:message key="label.purchases.instructions.customer"/>:</td>
			<td class="etiqueta_campo"  width="10%">
				<html:text property="instructionPurchaseSearchView.customerId"  styleClass="campo_texto" size="13"></html:text>
				<html:hidden property="instructionPurchaseSearchView.itemId" ></html:hidden>
			</td>
			<td class="etiqueta" width="4%" align="center"><bean:message key="label.purchases.instructions.balance"/>:</td>
			<td class="etiqueta_campo"  width="12%">
				<html:select property="instructionPurchaseSearchView.selectBalance" styleClass="campo_texto" >
					<html:option value="1"><bean:message key="label.selectbalance.major"/></html:option>
					<html:option value="2"><bean:message key="label.selectbalance.minor"/></html:option>
					<html:option value="3"><bean:message key="label.selectbalance.equals"/></html:option>
				</html:select>
				<html:text property="instructionPurchaseSearchView.balance"  styleClass="campo_texto_r" size="9"></html:text>
			</td>
			<td class="etiqueta" width="5%" align="center"><bean:message key="label.purchases.instructions.status"/>:</td>
			<td class="etiqueta_campo"  width="9%">
				<html:select property="instructionPurchaseSearchView.purchaseStatus" styleClass="campo_texto" >
					<html:option value="-1"><bean:message key="label.purchases.instructions.select"/></html:option>
	      			<html:option value="1"><bean:message key="label.purchaseinstructiondetail.status.1"/></html:option>
	      			<html:option value="2"><bean:message key="label.purchaseinstructiondetail.status.2"/></html:option>
	      			<html:option value="3"><bean:message key="label.purchaseinstructiondetail.status.3"/></html:option>
				</html:select>
			</td>
			<td class="etiqueta" width="10%" align="center"><bean:message key="label.purchases.instructions.line.status"/>:</td>
			<td class="etiqueta_campo"  width="9%">
				<html:select property="instructionPurchaseSearchView.purchaseDetailStatus" styleClass="campo_texto" >
					<html:option value="0"><bean:message key="label.purchases.instructions.select"/></html:option>
	      			<html:option value="1"><bean:message key="label.purchaseinstructiondetail.status.1"/></html:option>
	      			<html:option value="2"><bean:message key="label.purchaseinstructiondetail.status.2"/></html:option>
	      			<html:option value="3"><bean:message key="label.purchaseinstructiondetail.status.3"/></html:option>
				</html:select>
			</td>
			<td align="center" class="columnadatoPar"  width="8%">
				<input type="submit" value="<bean:message key="label.common.query"/>"  class="boton"/>
			</td>
		</tr>
	</table>
</html:form>
<table align="center" width="99%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>
		<td class="titulocolumna" align="center" width="3%" rowspan="2">
			<s:entidad nombreCortoEnt="NEW" permiso="ADMINISTRACION" nombreCortoMod="PROC" nombreCortoSub="INSTCOMP">
				<html:link action="/goInstructionPurchaseHeader?filters=news">
					<img alt="<bean:message key="common.add"/> <bean:message key="label.purchases.instructions"/>" src="images/nuevo.gif" border="0">
				</html:link>
			</s:entidad>
		</td>
		<td class="titulocolumna" align="center" width="6%" rowspan="2">
			<a href="#>" onclick="return submitInstructionPurchase(document.InstructionPurchaseSearchForm, 1,'<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchases.instructions.reference"/>
				<c:choose>
					<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>
		</td>
		<td class="titulocolumna" align="center" width="6%" rowspan="2">
			<a href="#>" onclick="return submitInstructionPurchase(document.InstructionPurchaseSearchForm, 2,'<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchases.instructions.status"/>
				<c:choose>
					<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>
		</td>
		<td class="titulocolumna" align="center" width="9%" rowspan="2">
			<a href="#>" class="ligas">
				<bean:message key="label.purchases.instructions.line"/>
				<c:choose>
					<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>
		</td>
		<td class="titulocolumna" align="center" width="26%" rowspan="2">
			<bean:message key="label.purchases.instructions.customer"/>
		</td>
		<td class="titulocolumna" align="center" width="20%" rowspan="2">
			<bean:message key="label.purchases.instructions.product"/>
			</a>
		</td>
		<td colspan="3" align="center" class="titulocolumna"><bean:message key="label.futurepurchase.query.quantity"/></td>
		<td class="titulocolumna" align="center" width="6%" rowspan="2">
			<bean:message key="label.purchases.instructions.line.status"/>
		</td>
	</tr>
	<tr>
		<td class="titulocolumna" align="center" width="8%">
			<bean:message key="label.purchases.instructions.contracts.topurchase"/>
		</td>
		<td class="titulocolumna" align="center" width="8%">
			<bean:message key="label.purchases.instructions.contracts.purchased"/>
		</td>
		<td class="titulocolumna" align="center" width="8%">
			<bean:message key="label.purchases.instructions.balance"/>
		</td>
	</tr>
<logic:present name="instructionViews">
	<logic:iterate name="instructionViews" id="instrucciones" indexId="int_i">
		<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">
			<td align="center">
				<logic:notEqual name="instrucciones" property="id" value="0">
					<s:entidad nombreCortoEnt="EDIT" permiso="ADMINISTRACION" nombreCortoMod="PROC" nombreCortoSub="INSTCOMP">
						<a href="editInstructionPurchaseHeader.do?purchaseInstructionId=<bean:write name="instrucciones" property="id"/>">
							<img alt="<bean:message key="common.edit"/> <bean:message key="label.purchases.instructions"/> <bean:write name="instrucciones" property="reference"/>" src="images/modificar.gif" border="0">
						</a>
					</s:entidad>
				</logic:notEqual>
			</td>
			<td align="center">
				<logic:notEqual name="instrucciones" property="id" value="0">
					<bean:write name="instrucciones" property="reference"/>
				</logic:notEqual>
			</td>
			<td align="center">
				<logic:notEqual name="instrucciones" property="id" value="0">
					<bean:write name="instrucciones" property="purchaseStatusDescription"/>
				</logic:notEqual>
			</td>
			<td align="center">
				<logic:notEqual name="instrucciones" property="rowNumber" value ="">
					<a href="#>" onclick="location.href = 'purchaseInstructionDetailsEdit.do?pid=<bean:write name="instrucciones" property="purchaseDetailId"/>'"><img alt="<bean:message key="label.purchases.instructions.reception.edit"/> <bean:write name="instrucciones" property="rowNumber"/> <bean:message key="label.purchases.instructions.reception.instruction"/> <bean:write name="instrucciones" property="reference"/>" width="12" height="12" src="images/edit_customer_item.png" border="0"></a>
					<s:entidad nombreCortoEnt="RECEIPT" permiso="ADMINISTRACION" nombreCortoMod="PROC" nombreCortoSub="INSTCOMP">
						<a href="#>" onclick="location.href = 'goToPurchaseDetailReception.do?purchaseInstructionDetailId=<bean:write name="instrucciones" property="purchaseDetailId"/>'"><img alt="<bean:message key="label.purchases.instructions.reception"/> <bean:write name="instrucciones" property="rowNumber"/> <bean:message key="label.purchases.instructions.reception.instruction"/> <bean:write name="instrucciones" property="reference"/>" width="12" height="12" src="images/hand.png" border="0"></a>
					</s:entidad>
					<s:entidad nombreCortoEnt="ATTAFILE" permiso="ADMINISTRACION" nombreCortoMod="PROC" nombreCortoSub="INSTCOMP">
						<a href="#>" onclick="location.href='purchaseInstructionDetailAttachment.do?pid=<bean:write name="instrucciones" property="purchaseDetailId"/>';" class="ligas"><img alt="<bean:message key="label.purchases.instructions.attachment"/> <bean:write name="instrucciones" property="rowNumber"/> <bean:message key="label.purchases.instructions.reception.instruction"/> <bean:write name="instrucciones" property="reference"/>" src="images/attach.png" border="0" width="12" height="12"></a>
					</s:entidad>
					<bean:write name="instrucciones" property="rowNumber"/>
				</logic:notEqual>				
			</td>
			<td align="left">
				<logic:notEqual name="instrucciones" property="rowNumber" value ="">
					<bean:write name="instrucciones" property="customerId"/> - <bean:write name="instrucciones" property="customerName"/>
				</logic:notEqual>
			</td>
			<td align="center">
				<b><bean:write name="instrucciones" property="itemCount"/></b> <fmt:message key="label.purchaseinstructiondetail.product.selected"/>
			</td>
			<td align="right">
				<logic:notEqual name="instrucciones" property="rowNumber" value ="">
					<bean:write name="instrucciones" property="contractQuantity"/>
				</logic:notEqual>
			</td>
			<td align="right">
				<logic:notEqual name="instrucciones" property="rowNumber" value ="">
					<bean:write name="instrucciones" property="contractQuantityPurchased"/>
				</logic:notEqual>
			</td>
			<td align="right">
				<logic:equal name="instrucciones" property="purchaseStatus" value ="1">
					<logic:equal name="instrucciones" property="purchaseDetailStatus" value ="1">
						<bean:write name="instrucciones" property="contractBalance"/>
					</logic:equal>
				</logic:equal>
			</td>
			<td align="center">
				<bean:write name="instrucciones" property="purchaseDetailStatusDescription"/>
			</td>
		</tr>
	</logic:iterate>
</logic:present>
</table>
<br/>
